<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Vue中的列表过渡</title>
  <script src="vue.js"></script>
  <style>
      .v-enter,.v-leave-to{
        opacity: 0;
      }
      .v-enter-active,.v-leave-active{
        transition:opacity 2s;
      }
  </style>
</head>
<body>
<!--在列表外层加上transition-group  相当于在每一层div标签外加上一个transition标签-->

<div id="app">
  <transition-group>
    <div v-for="item of list" :key="item.id">
      {{item.title}}
    </div>
  </transition-group>
  <!--<transition>-->
    <!--<div>hello world</div>-->
  <!--</transition> -->
  <!--<transition>-->
    <!--<div>hello world</div>-->
  <!--</transition> -->
  <!--<transition>-->
    <!--<div>hello world</div>-->
  <!--</transition>-->
  <button @click="handleBtnClick">Add</button>
</div>
<script>
  var count=0;
  var vm=new Vue({
    el:"#app",
    data:{
      list:[]
    },
    methods:{
      handleBtnClick:function(){
         this.list.push({
            id:count++,
            title:'hello world'
         })
      }
    }
  })
</script>
</body>
</html>
